/********************************************************************************
 *      Copyright:  (C) 2025 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  getdata.h
 *    Description:  This file 
 *
 *        Version:  1.0.0(30/04/25)
 *         Author:  chenhongyu0822@163.com
 *      ChangeLog:  1, Release initial version on "30/04/25 22:08:51"
 *                 
 ********************************************************************************/

#ifndef _GETDATA_H
#define _GETDATA_H

#include <stdint.h>

#define       RPI_LEN        8
#define       TEMP_LEN       4
#define       TIME_LEN       19
 
typedef struct {
       char     rpi[RPI_LEN+1];
       float    temp;
       char     time[TIME_LEN+1];
}Sample_Data_t;

extern Sample_Data_t data;

typedef int (* pack_data_t)(Sample_Data_t *pack_info, uint8_t  *pack_buf, int size);

extern int get_temperature(float *temp);

extern void get_id(char *rpi_id, int size);

extern void get_time(char *sample_time, int size);

extern int segmented_pack(Sample_Data_t *pack_info, uint8_t *pack_buf, int size);

extern int json_pack(Sample_Data_t *pack_info,     uint8_t *pack_buf, int size);

extern uint16_t crc_t(const uint8_t *data, size_t length);

extern uint16_t to_big_endian(uint16_t num);

extern int tlv_pack(Sample_Data_t *pack_info, uint8_t *pack_buf, int size);

#endif
